package POJO;

import java.io.Serializable;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "STORE_PRODUCT_DETAIL")
@AssociationOverrides({
	@AssociationOverride(name = "pk.store", joinColumns = @JoinColumn(name = "Store_Id")),
	@AssociationOverride(name = "pk.productDetail", joinColumns = @JoinColumn(name = "Product_Detail_Id"))
})
public class StoreProductDetail implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6024310535595509855L;
	
	@EmbeddedId
	private KeyStoreProductDetail pk;
	
	@Column(name = "Count")
	private long count;

	public StoreProductDetail() {
		super();
	}

	public StoreProductDetail(Store store, ProductDetail productDetail, long count) {
		super();
		this.pk = new KeyStoreProductDetail(store, productDetail);
		this.count = count;
	}

	public KeyStoreProductDetail getPk() {
		return pk;
	}

	public void setPk(KeyStoreProductDetail pk) {
		this.pk = pk;
	}

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}
	
	@Transient
	public Store getStore(){
		return pk.getStore();
	}
	
	public void setStore(Store store){
		pk.setStore(store);
	}
	
	@Transient 
	public ProductDetail getProductDetail(){
		return pk.getProductDetail();
	}
	
	public void setProductDetail(ProductDetail productDetail){
		pk.setProductDetail(productDetail);
	}
	
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
 
		StoreProductDetail that = (StoreProductDetail) o;
 
		if (getPk() != null ? !getPk().equals(that.getPk())
				: that.getPk() != null)
			return false;
 
		return true;
	}
 
	public int hashCode() {
		return (getPk() != null ? getPk().hashCode() : 0);
	}
}




